//
//  UIlabel + Extension.swift
//  WeiBo_One
//
//  Created by 李炎 on 15/10/25.
//  Copyright © 2015年 蜡笔小炎. All rights reserved.
//

import UIKit

extension UILabel {
    
//    convenience init(title: String , fontSize: CGFloat? = 17, color:UIColor? = UIColor(white: 0.3, alpha: 1.0)) {
//        
//        self.init()
//        
//        text = title
//        font = UIFont.systemFontOfSize(fontSize!)
//        textColor = color
//        sizeToFit()
//    }
    
    /// 便利构造函数
    /// 参数后面的值是参数的默认值，如果不传递，就使用默认值
    convenience init(title: String, fontSize: CGFloat = 14, color: UIColor = UIColor.darkGrayColor(), screenInset: CGFloat = 0.0) {
        self.init()
        
        text = title
        textColor = color
        font = UIFont.systemFontOfSize(fontSize)
        
        numberOfLines = 0
        
        if screenInset > 0 {
            textAlignment = .Left
            preferredMaxLayoutWidth = UIScreen.mainScreen().bounds.width - 2 * screenInset
        } else {
            textAlignment = .Center
        }
    }
}